Skip to content

docs: Add guidelines for TypeScript Utility Types usage#48

Open
lucioerlan wants to merge 1 commit intojuntossomosmais:mainfrom
lucioerlan:doc/add-typescript-utility-types
Open

docs: Add guidelines for TypeScript Utility Types usage#48
lucioerlan wants to merge 1 commit intojuntossomosmais:mainfrom
lucioerlan:doc/add-typescript-utility-types

Conversation

@lucioerlan
Copy link

This pull request presents a practical guide on how to use TypeScript's Utility Types effectively. We cover essential types like Partial<T>, Readonly<Type>, Record<Keys, Type>, Pick<Type, Keys>, and Omit<Type, Keys>, which are fundamental in my day-to-day programming.

They are super useful for improving typing in various situations, from manipulating objects to defining interfaces for components. With them, we achieve fine control over our data, avoiding those annoying typing errors and making our code clearer and easier to maintain.

References:
https://www.typescriptlang.org/docs/handbook/utility-types.html

}
```

### 11.7 TypeScript Utility Types
Copy link
Contributor

@rogigs rogigs Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great ideas @lucioerlan 💡

What do you think about Typeof Type Operator ?

I've been using those points who you showed. And I've been use too the typeof to the case typing utils, for instance

Screenshot 2023-12-14 054838

Typescript inferred the item as

{
    title: string;
    images: {
        name: string;
        legend: string;
    }[];
}

More about Type Manipulation: https://www.typescriptlang.org/docs/handbook/2/types-from-types.html

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tks @rogigs o/

it's beneficial because it ensures that your types are tight and evolve with your data structures.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants